package com.ruoyi.web.controller.memberCoupon;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TableTimeCard;
import com.ruoyi.system.service.ITableTimeCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 桌台时长卡，记录桌台时长卡的基础信息、购买限制及适用范围Controller
 *
 * @author ruoyi
 * @date 2025-05-22
 */
@Api(tags="桌台时长卡")
@RestController
@RequestMapping("/system/tableTimeCard")
public class TableTimeCardController extends BaseController
{
    @Autowired
    private ITableTimeCardService tableTimeCardService;

    /**
     * 查询桌台时长卡列表
     */
    @ApiOperation("查询桌台时长卡列表")
    @PreAuthorize("@ss.hasPermi('system:card:list')")
    @GetMapping("/list")
    public TableDataInfo list(TableTimeCard tableTimeCard)
    {
        startPage();
        List<TableTimeCard> list = tableTimeCardService.selectTableTimeCardList(tableTimeCard);
        return getDataTable(list);
    }

    /**
     * 导出桌台时长卡列表
     */
    @ApiOperation("导出桌台时长卡列表")
    @PreAuthorize("@ss.hasPermi('system:card:export')")
    @Log(title = "桌台时长卡，记录桌台时长卡的基础信息、购买限制及适用范围", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TableTimeCard tableTimeCard)
    {
        List<TableTimeCard> list = tableTimeCardService.selectTableTimeCardList(tableTimeCard);
        ExcelUtil<TableTimeCard> util = new ExcelUtil<TableTimeCard>(TableTimeCard.class);
        util.exportExcel(response, list, "桌台时长卡，记录桌台时长卡的基础信息、购买限制及适用范围数据");
    }

    /**
     * 通过id获取桌台时长卡详细信息
     */
    @ApiOperation("通过id获取桌台时长卡详细信息")
    @PreAuthorize("@ss.hasPermi('system:card:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tableTimeCardService.selectTableTimeCardById(id));
    }

    /**
     * 新增桌台时长卡
     */
    @ApiOperation("新增桌台时长卡")
    @PreAuthorize("@ss.hasPermi('system:card:add')")
    @Log(title = "桌台时长卡，记录桌台时长卡的基础信息、购买限制及适用范围", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TableTimeCard tableTimeCard)
    {
        return toAjax(tableTimeCardService.insertTableTimeCard(tableTimeCard));
    }

    /**
     * 修改桌台时长卡
     */
    @ApiOperation("修改桌台时长卡")
    @PreAuthorize("@ss.hasPermi('system:card:edit')")
    @Log(title = "桌台时长卡，记录桌台时长卡的基础信息、购买限制及适用范围", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TableTimeCard tableTimeCard)
    {
        return toAjax(tableTimeCardService.updateTableTimeCard(tableTimeCard));
    }

    /**
     * 通过id批量删除桌台时长卡信息
     */
    @ApiOperation("通过id批量删除桌台时长卡信息")
    @PreAuthorize("@ss.hasPermi('system:card:remove')")
    @Log(title = "桌台时长卡，记录桌台时长卡的基础信息、购买限制及适用范围", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tableTimeCardService.deleteTableTimeCardByIds(ids));
    }
}
